package com.you.base.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 代理实现类
 */
public class UserServiceProxy implements InvocationHandler {

    public Object realObj; //真正的是实现类

    public UserServiceProxy(Object realObj) {
        this.realObj = realObj;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        //调用真正的实现类的方法
        Object result = method.invoke(realObj, args);
        return result;
    }
}
